use "C:\Users\ibo6\OneDrive - The Pennsylvania State University\Working Papers\Target Hardening\v10 Terrorism and Political Violence\R & R\Analysis\rdyads2.dta", replace

* TABLE 8A
** Model 8: Instate attacks (simple)
nbreg instate c.b_l##c.str_intel_log_l total_l, robust cluster(dyadid)
estimates store t3_instate_simpleINTER

ssc install estout
label variable b_l "Success rate of instate attacks (lagged)"
label variable total_l "Total number of attacks (lagged)"
label variable str_intel_log_l "Hardening (lagged)"
label variable a_l "Success rate against hard targets (lagged)"
label variable suictot_l "Ratio of suicide attacks (lagged)"
label variable coin_deaths_log_l "COIN casualties (lagged)"
label variable inten "Conflict intensity"
label variable epr "Ethnic fractionalization"
label variable ideology "Group ideology"

label define ideology 1 "Ethnonationalist" 2 "Religious" 3 "Leftist" 4 "Other"
label values ideology ideology

esttab t3_instate_simpleINTER using apptable8A.csv, b(%5.3f)  mlabel("Instate" "Instate" "Instate") se starlevels(* 0.1 ** 0.05 *** 0.01) label noconstant nobaselevels title("Negative Binomial Models of Instate Target Selection in Relevant State-Group Dyads in India, 2004-2016") addnotes("The dependent variables are the number of instate attacks committed in a given relevant state-group dyad in a given year. An attack is coded as an instate attack if the state where the attack occurred is the primary area of operation of the group perpetrating the attack. Robust standard errors clustered on relevant state-group dyads are presented in parentheses.")


* Predictions
estimates restore t3_instate_simpleINTER
margins, at(b_l=(0.7(0.1)0.9) str_intel_log=(0(4)8)) vsquish
marginsplot, noci x(str_intel_log_l) recast(line) xlabel(0(4)8)
